﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OpenSunTracker.RestClient;

namespace OSTWin
{
    /// <summary>
    /// Interaction logic for ucState.xaml
    /// </summary>
    public partial class ucState : UserControl
    {
        public ucState()
        {
            InitializeComponent();


        }

        public OpenSunTrackerClient Client { get { return DataContext as OpenSunTrackerClient; } }

        public void UpdateVisuals()
        {
            if (!Client.HasState)
                return;

            //free bytes
            if (Client.State.FreeBytes >= 30000)
                FreeBytes.Background = new SolidColorBrush(Colors.LightGreen);
            else if (Client.State.FreeBytes < 30000 && Client.State.FreeBytes > 25000)
                FreeBytes.Background = new SolidColorBrush(Colors.Orange);
            else if (Client.State.FreeBytes <= 25000)
                FreeBytes.Background = new SolidColorBrush(Colors.Red);

            //windspeed-alarm

            if (Client.State.TrackingWindAlarm == "True")
                WindAlarm.Background = new SolidColorBrush(Colors.Red);
            else
                WindAlarm.Background = new SolidColorBrush(Colors.LightGreen);
        }

    }
}
